home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWXDRistream (Unix only) - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include <rw/xdrstrea.h>
-
-
-
-
- XDR xdr;
- xdrstdio_create(&xdr, stdin, XDR_DECODE);
- RWXDRistream rw_xdr(&xdr);
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- Class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm is a portable input stream based on XDR routines.
- Class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm encapsulates a portion of the XDR library routines
- that are used for external data representation. XDR routines allow
- programmers to describe arbitrary data structures in a machine-
- independent fashion. Data for remote procedure calls (RPC) are
- transmitted using XDR routines. Class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm enables one to decode
- an XDR structure to a machine representation. Class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm
- provides the capability to decode all the standard data types and vectors
- of those data types. An XDR stream must first be created by calling the
- appropriate creation routine. XDR streams currently exist for
- encoding/decoding of data to or from standard iostreams and file streams,
- TCP/IP connections and Unix files, and memory. These creation routines
- take arguments that are tailored to the specific properties of the
- stream. After the XDR stream has been created, it can then be used as
- the argument to the constructor for a RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm object. RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm
- can be interrogated as to the status of the stream using member functions
- bbbbaaaadddd(((()))), cccclllleeeeaaaarrrr(((()))), eeeeooooffff(((()))), ffffaaaaiiiillll(((()))), ggggoooooooodddd(((()))), and rrrrddddssssttttaaaatttteeee(((()))).
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- The example that follows is a "reader" program that decodes an XDR
- structure from a file stream. The example for class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm is the
- "writer" program that encodes the XDR structures onto the file stream.
- The library that supports XDR routines must be linked in. The name of
- this library is not standard.
-
- #include <rw/xdrstrea.h>
-
-
-
- #include <rw/rstream.h>
- #include <stdio.h>
- main(){
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- XDR xdr;
- FILE* fp = fopen("test","r+");
- xdrstdio_create(&xdr, fp, XDR_DECODE);
-
- RWXDRistream rw_xdr(&xdr);
- int data;
- for(int i=0; i<10; ++i) {
- rw_xdr >> data; // decode integer data
- if(data == i)
- cout << data << endl;
- else
- cout << "Bad input value" << endl;
- }
- fclose(fp);
- }
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm(XDR* xp);
-
-
- Initialize an RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm from the XDR structure xxxxpppp.
-
- RRRRWWWWXXXXDDDDrrrriiiissssttttrrrreeeeaaaammmm(streambuf*);
-
-
- Initialize RWXDRistream with a pointer to streambuf. Streambuf must be
- already allocated.
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm(istream&);
-
-
- Initialize RWXDRistream with an input stream.
-
- PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
- ~virtual RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm();
-
-
- Deallocate previously allocated resources.
-
-
-
-
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
- virtual int
- ggggeeeetttt();
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets and returns the next character from
- the XDR input stream. If the operation fails, it sets the failbit and
- returns EEEEOOOOFFFF.
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- virtual RWvistream&
- ggggeeeetttt(char& c);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next character from the XDR
- input stream and stores it in cccc. If the operation fails, it sets the
- failbit. This member only preserves ASCII numerical codes, not the
- coresponding character symbol.
-
- virtual RWvistream&
- ggggeeeetttt(wchar_t& wc);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next wide character from the
- XDR input stream and stores it in wwwwcccc. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(unsigned char& c);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next unsigned character from
- the XDR input stream and stores it in cccc. If the operation fails, it sets
- the failbit.
-
- virtual RWvistream&
- ggggeeeetttt(char* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN characters from the
- XDR input stream and stores them in vvvv. If the operation fails, it sets
- the failbit.
-
- virtual RWvistream&
- ggggeeeetttt(unsigned char* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN unsigned characters
- from the XDR input stream and stores them in vvvv. If the operation fails,
- it sets the failbit.
-
- virtual RWvistream&
- ggggeeeetttt(double* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN ddddoooouuuubbbblllleeees from the XDR
- input stream and stores them in vvvv. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(float* v, size_t N);
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN ffffllllooooaaaatttts from the XDR
- input stream and stores them in vvvv. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(int* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN iiiinnnntttts from the XDR
- input stream and stores them in vvvv. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(unsigned int* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN unsigned iiiinnnntttts from
- the XDR input stream and stores them in vvvv. If the operation fails, it
- sets the failbit.
-
- virtual RWvistream&
- ggggeeeetttt(long* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN lllloooonnnnggggs from the XDR
- input stream and stores them in vvvv. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(unsigned long* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN unsigned lllloooonnnnggggs from
- the XDR input stream and stores them in vvvv. If the operation fails, it
- sets the failbit.
-
- virtual RWvistream&
- ggggeeeetttt(short* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN sssshhhhoooorrrrtttts from the XDR
- input stream and stores them in vvvv. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ggggeeeetttt(unsigned short* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN unsigned sssshhhhoooorrrrtttts from
- the XDR input stream and stores them in vvvv. If the operation fails, it
- sets the failbit.
-
-
-
-
- PPPPaaaaggggeeee 4444
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- virtual RWvistream&
- ggggeeeetttt(wchar_t* v, size_t N);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets a vector of NNNN wide characters from
- the XDR input stream and stores them in vvvv. If the operation fails, it
- sets the failbit.
-
- virtual RWvistream&
- ggggeeeettttSSSSttttrrrriiiinnnngggg(char* s, size_t maxlen);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Restores a character string from the XDR
- input stream that was stored to the XDR output stream with
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm::::::::ppppuuuuttttssssttttrrrriiiinnnngggg and stores the characters in the array starting
- at ssss. The function stops reading at the end of the string or after
- mmmmaaaaxxxxlllleeeennnn----1111 characters, whichever comes first. If mmmmaaaaxxxxlllleeeennnn----1111 characters have
- been read and the mmmmaaaaxxxxlllleeeennnnth character is not the string terminator, then
- the failbit of the stream will be set. In either case, the string will
- be terminated with a null byte.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(char& c );
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next character from the XDR
- input stream and stores it in cccc. If the operation fails, it sets the
- failbit. This member attempts to preserve the symbolic characters' values
- transmitted over the stream.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(double& d);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next ddddoooouuuubbbblllleeee from the XDR input
- stream and stores it in dddd. If the operation fails, it sets the failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(float& f);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next ffffllllooooaaaatttt from the XDR input
- stream and stores it in ffff. If the operation fails, it sets the failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(int& i);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next integer from the XDR input
- stream and stores it in iiii. If the operation fails, it sets the failbit.
-
-
-
-
-
- PPPPaaaaggggeeee 5555
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(long& l);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next lllloooonnnngggg from the XDR input
- stream and stores it in llll. If the operation fails, it sets the failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(short& s);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next sssshhhhoooorrrrtttt from the XDR input
- stream and stores it in ssss. If the operation fails, it sets the failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(wchar_t& wc);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next wide character from the
- XDR input stream and stores it in wwwwcccc. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned char& c);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next unsigned character from
- the XDR input stream and stores it in cccc. If the operation fails, it sets
- the failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned int& i);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next unsigned integer from the
- XDR input stream and stores it in iiii. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned long& l);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next unsigned lllloooonnnngggg from the XDR
- input stream and stores it in llll. If the operation fails, it sets the
- failbit.
-
- virtual RWvistream&
- ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned short& s);
-
-
- Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm. Gets the next unsigned sssshhhhoooorrrrtttt from the
- XDR input stream and stores it in ssss. If the operation fails, it sets the
-
-
-
- PPPPaaaaggggeeee 6666
-
-
-
-
-
-
- RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
-
-
-
- failbit.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 7777
-
-
-
-